package beyjava.model;

import java.util.ArrayList;



/**
 * @author BEYJAVA
 * model class Resource
 */
public class Resource {
private Integer resourceID;
private ArrayList<Task> rsTasks = null;
private String resourceType;
	 /**
	 * @param resourceType
	 * @param resourceID
	 * constructor of Resource class
	 */
	public  Resource(String resourceType, Integer resourceID){
	   rsTasks = new ArrayList<Task>();
	   this.resourceType = resourceType;
	   this.resourceID = resourceID;
    }
	/**
	 * @param resourceID
	 */
	public void setResourceID(Integer resourceID) {
	   this.resourceID = resourceID;
	}
	/**
	 * @return resourceID
	 */
	public Integer getResourceID() {
	   return resourceID;
	}
	/**
	 * @return rsTasks
	 */
	public ArrayList<Task> getRsTasks() {
		return rsTasks;
	}
	/**
	 * @param rsTasks
	 */
	public void setRsTasks(ArrayList<Task> rsTasks) {
		this.rsTasks = rsTasks;
	}
	/**
	 * @param task
	 */
	public void addTaskToResource(Task task){
	   rsTasks.add(task);
	}
	/**
	 * @param task
	 */
	public void removeTaskFromResource(Task task){
	   rsTasks.remove(task);
	}
	/**
	 * @param resourceType
	 */
	public void setResourceType(String resourceType) {
	   this.resourceType = resourceType;
	}
	/**
	 * @return resourceType
	 */
	public String getResourceType() {
	   return resourceType;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((resourceID == null) ? 0 : resourceID.hashCode());
		result = prime * result
				+ ((resourceType == null) ? 0 : resourceType.hashCode());
		result = prime * result + ((rsTasks == null) ? 0 : rsTasks.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Resource other = (Resource) obj;
		if (resourceID == null) {
			if (other.resourceID != null)
				return false;
		} else if (!resourceID.equals(other.resourceID))
			return false;
		if (resourceType == null) {
			if (other.resourceType != null)
				return false;
		} else if (!resourceType.equals(other.resourceType))
			return false;
		if (rsTasks == null) {
			if (other.rsTasks != null)
				return false;
		} else if (!rsTasks.equals(other.rsTasks))
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "Resource [resourceID=" + resourceID + ", rsTasks=" + rsTasks
				+ ", resourceType=" + resourceType + "]";
	}
}
